const mongoose = require('mongoose');
const Schema = mongoose.Schema;

const DeptSchema = new Schema({
  name: { 
    type: String, 
    required: true 
  },
  parentId: {
    type: Schema.Types.ObjectId, 
    ref: 'Dept', 
    default: null 
  },
  isDisplay: { 
    type: Boolean, 
    required: true 
  },
  contactPerson: {
    name: String,
    phoneNumber: String
  },
  description: String,
  status: {
    type: String,
    enum: ['正常', '停用'],
    default: '正常'
  }
});

module.exports = mongoose.model('Dept', DeptSchema);